package com.itheima.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.dao.GradeDao;
import com.itheima.domain.Grade;
import com.itheima.service.GradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GradeServiceImpl implements GradeService {

    @Autowired
    private GradeDao gradeDao;

    @Override
    public void save(Grade grade) {
        gradeDao.save(grade);
    }

    @Override
    public void delete(Integer gradeid) {
        gradeDao.delete(gradeid);
    }

    @Override
    public void update(Grade grade) {
        gradeDao.update(grade);
    }

    @Override
    public Grade findById(Integer gradeid) {
        return gradeDao.findById(gradeid);
    }

    @Override
    public List<Grade> findAll() {
        return gradeDao.findAll();
    }

    @Override
    public PageInfo<Grade> findAll(int page, int size) {
        PageHelper.startPage(page, size);
        List<Grade> all = gradeDao.findAll();
        return new PageInfo<Grade>(all);
    }
}
